<template>
    <div>
      <div>
        <div class='content-title'>
          <div class='content-title-parent'>电商管理</div>
          /
          <div class='content-title-child'>自定义提醒策略</div>
        </div>
        <hr class='content-hr'/>
      </div>
    <div class="div-form remindStrateForm" style="width:660px;margin-top:10px"  v-bind:style="{marginLeft: marginWidth + 'px'}">
      <el-form :model="messageForm" ref="messageForm" label-width="100px" :rules="messageFormRules" >
        <el-form-item label="提醒内容：" prop="messageId" >
          <div class='form-gray'>
            <el-input v-model="messageForm.messageId" @keyup.native="enterEvent($event, 'messageForm', 'messageId')" style="width:240px" placeholder="请输入自定义提醒内容编号"></el-input>
            <el-button type="primary" style="background-color:#2280E9;border-color:#2280E9" @click="getMessageListFro()">挑选</el-button>
            <el-button type="success" style="margin-left:20px" @click="getMessageByIdFro(1)">查询</el-button>
            <div class='logistics-info' style="width:80%" v-show="messageContentVisible">
              <span class='info-time info-title' >信息标题：</span>
              <span class='info-content-title' style="width:80%;display:inline-block">{{messageForm.messageTitle}}</span>
              <div style='clear:both'></div>
              <span class='info-time info-title' >信息内容：</span>
              <span class='info-content-content' style="width:80%;display:inline-block" >{{messageForm.content}}</span>
            </div>     
            <!-- <div v-show="messageContentVisible">
              <span class="info-time info-title">信息标题：</span>
              <span class="info-content info-content-title">{{messageForm.messageTitle}}</span>
              <div style='clear:both'></div>
              <span class="info-time info-title">信息标题：</span>
              <span class="info-content info-content-content">{{messageForm.content}}</span>
            </div> -->
          </div>
        </el-form-item>
        <el-form-item label="发送对象：" prop="customType" >
          <div class='form-gray'>
              <el-select v-model="messageForm.customType" style="width:240px" placeholder="">
                <el-option
                  v-for="item in customTypeList"
                  :key="item"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
          </div>
        </el-form-item>
        <el-form-item label="发送类型：" prop="isSend">
          <div class='form-gray'>
            <el-checkbox v-model="messageForm.isAndroid">Android</el-checkbox>
            <el-checkbox v-model="messageForm.isIOS">IOS</el-checkbox>
          </div>
        </el-form-item>
        <el-form-item label="提醒方式：" prop="isRemind" >
          <div class='form-gray'>
            <el-checkbox v-model="messageForm.tuisong"  @change="setRemindWay" >推送</el-checkbox>
            <el-checkbox v-model="messageForm.isQidong">启动APP，进入APP首页</el-checkbox>
            <hr style="height:1px;border:none;border-top:1px solid #C0C4CC;" />
            <el-checkbox v-model="messageForm.text"  @change="setRemindWay">短信</el-checkbox>
          </div>
        </el-form-item>
        <!-- <el-form-item label="优先度：" prop="name">
          <div class='form-gray'>
            <el-checkbox v-model="messageForm.isPriority">优先</el-checkbox>
          </div>
        </el-form-item> -->
        <el-form-item label="提醒时间：" prop="remindTime" class='remindClassError'>
          <div class='form-gray'>
            <div class='logistics-info remindTimeClass' >
              <el-form-item class='el-form-item-title '>
                <el-radio-group v-model="messageForm.pushMode" @change="changeRemindTime">
                  <el-radio label="1">循环</el-radio>
                </el-radio-group>
              </el-form-item>
              <div style='clear:both'></div>
              <span class='info-content' style="padding-bottom:0px;margin-left:16px" >
                <el-form-item label="时间区间：" prop='jiangeTime'>
                  <el-date-picker
                    :disabled="remindTimeEdit"
                    style="width:380px"
                    v-model="messageForm.jiangeTime"
                    type="datetimerange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    :picker-options="pickerOptions0">
                  </el-date-picker>
                </el-form-item>
                <div style='clear:both'></div>
                <el-form-item label="间隔：" prop="hoursMins" >
                  <el-select v-model="messageForm.hours" :disabled="remindTimeEdit" style="width:80px"  placeholder="">
                    <el-option
                      v-for="item in hourList"
                      :key="item"
                      :value="item">
                    </el-option>
                  </el-select>
                  <span style="margin-right:5px;margin-left:5px">小时</span>
                  <el-select v-model="messageForm.mins" :disabled="remindTimeEdit" style="width:80px"  placeholder="">
                    <el-option
                      v-for="item in minsList"
                      :key="item"
                      :value="item">
                    </el-option>
                  </el-select>
                  <span style="margin-left:5px">分钟</span>
                </el-form-item>
                <!-- <el-select style="width:60px;float:left" v-model="testmodel">
                  <el-option label="10" value="10"></el-option>
                </el-select> -->
                <div style='clear:both;'></div>
                <el-form-item label="循环次数：" prop="roundNum">
                  <el-input style="width:80px" :disabled="true" value="23" v-model="setRoundNum"></el-input>
                  <span style="margin-left:5px">次</span>
                </el-form-item>
              </span>
            </div>
            <hr style="height:1px;border:none;border-top:1px solid #C0C4CC;" />
            <div class='logistics-info remindTimeClass' style="width:100%;margin-top:10px">
              <el-form-item class='el-form-item-title'>
                 <el-radio-group v-model="messageForm.pushMode" @change="changeRemindTime">
                  <el-radio label="2">自定义</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="" prop="dataPickerTime" class='info-content' style="margin-left:20px;padding-bottom:0px;clear:both">
                <el-date-picker
                  v-model="messageForm.datePicker1"
                  style="width:200px;float:left"
                  type="datetime"
                  clearable
                  :picker-options="pickerOptions0"
                  :disabled="!remindTimeEdit"
                  placeholder="选择日期时间">
                </el-date-picker>
                <el-button style="float:left;margin-left:10px" type="success" :disabled="!remindTimeEdit" @click="addDatePicker">增加</el-button>
                <el-date-picker
                  v-for="(item, index) in messageForm.datePickerForm"
                  v-model="item.value"
                  :key="item.key"
                  clearable
                  :picker-options="pickerOptions0"
                  :disabled="!remindTimeEdit"
                  style="width:200px;float:left;clear:left;margin-top:5px"
                  type="datetime"
                  placeholder="选择日期时间"
                >
                </el-date-picker>
              </el-form-item>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <div style="text-align:center;clear:both">
        <el-button type="primary" @click="submitAdd()" >请再次确认提醒策略，提交</el-button>
      </div>
      <el-dialog 
        title="提醒内容选择："
        :visible.sync="messageVisible"
        class="remindStrateDialog"
        width="500px"
        @close="messageForm.pageNum=1;messageForm.messageIdQuery = ''">
        <el-input v-model="messageForm.messageIdQuery" placeholder="请输入内容编号进行查询" size="small" style="width:40%"></el-input>
        <el-button size="small" type="primary" @click="getMessageByIdFro(2)">查询</el-button>
        <div class="inner" style="margin-top:5px">
          <div class="innerbox">
            <el-table
              size="mini"
              :data="filterFormFro.tableData" 
              :border="true"
              v-loading="loading"
              :element-loading-text="loadingText"
              element-loading-spinner="el-icon-loading"
              :row-class-name="tableRowClassName"
              :header-cell-class-name = "tableHeaderClassName"
              @row-dblclick="doubleClick"
              highlight-current-row
              style="width: 100%;">
                <el-table-column prop="index" label="序号" min-width=10%>
                </el-table-column>
                <el-table-column prop="messageId" label="内容编号" min-width=20%>
                </el-table-column>
                <el-table-column prop="messageTitle" label="内容主题"  min-width=20%>
                </el-table-column>
                <el-table-column prop="content" label="内容明细" min-width=50%>
                </el-table-column>
            </el-table>
          </div>
          </div>
        <!--分页-->
        <div class="pagination" style="text-align:center" v-show="paginationVisible">
            <el-pagination
              @current-change="handleCurrentChange"
              background
              :current-page="messageForm.pageNum"
              :page-size="20"
              layout="total, prev, pager, next"
              :page-count="filterFormFro.allPages">
            </el-pagination>
        </div>
      </el-dialog>
    </div>
    </div>
</template>
<script>
import '../../../static/css/businessPlat/common.css'
import apiBus from '../../api/businessPlat/apiBus.js'
import '../../../static/css/businessPlat/remindStrate.css'
export default {
  created () {
  },
  data () {
    var checkHotlineNum = (rule, value, callback) => { // 内容编号验证
      if (/^[A-Z]{2}\d\d\d\d$/.test(value)) {
        callback()
      } else {
        this.messageContentVisible = false
        callback(new Error('内容编号为两位大写英文字母+四位流水号'))
      }
    }
    var checkSend = (rule, value, callback) => { // 发送类型验证
      if (!this.messageForm.isAndroid && !this.messageForm.isIOS) {
        callback(new Error('请选择发送手机类型'))
      } else {
        callback()
      }
    }
    var checkRemind = (rule, value, callback) => { // 提醒方式验证
      if (!this.messageForm.text && !this.messageForm.tuisong) {
        callback(new Error('请选择提醒类型'))
      } else {
        callback()
      }
    }
    var checkRemindTime = (rule, value, callback) => { // 提醒时间验证
      if (this.messageForm.pushMode === '') {
        callback(new Error('请选择提醒时间'))
      } else {
        callback()
      }
    }
    var checkJianGe = (rule, value, callback) => { // 提醒时间-循环-时间区间验证
      if (this.messageForm.pushMode === '1') {
        if (this.messageForm.jiangeTime && this.messageForm.jiangeTime.length > 0) {
          callback()
        } else {
          callback(new Error('请选择时间区间'))
        }
      } else {
        callback()
      }
    }
    var checkHoursMins = (rule, value, callback) => { // 提醒时间-循环-间隔（小时分钟）验证
      if (this.messageForm.pushMode === '1') {
        if (!this.messageForm.hours && !this.messageForm.mins) {
          callback(new Error('请选择间隔时间'))
        } else {
          callback()
        }
      } else {
        callback()
      }
    }
    var checkRoundNum = (rule, value, callback) => { // 提醒时间-循环-循环次数验证
      if (this.setRoundNum > 10) {
        callback(new Error('循环次数最多不超过10次'))
      } else {
        callback()
      }
    }
    var checkDataPicker = (rule, value, callback) => { // 提醒时间-循环-循环时间验证
      if (this.messageForm.pushMode === '2') {
        let startTimes = []
        if (this.messageForm.datePicker1 && this.messageForm.datePicker1 !== '') {
          startTimes.push(this.formatDateFro(this.messageForm.datePicker1))
        }
        for (let i = 0; i < this.messageForm.datePickerForm.length; i++) {
          if (this.messageForm.datePickerForm[i].value && this.messageForm.datePickerForm[i].value !== '') {
            startTimes.push(this.formatDateFro(this.messageForm.datePickerForm[i].value))
          }
        }
        if (startTimes.length > 0) {
          callback()
        } else {
          callback(new Error('请选择自定义日期时间'))
        }
      } else {
        callback()
      }
    }
    return {
      loadingText: '正在拼命加载中，请稍等......',
      loading: true,
      marginWidth: '', // 样式margin-left
      hourList: [0, 1, 2, 3, 4, 5, 6, 7, 8], // 间隔时间列表
      minsList: [0, 5, 15, 30], // 间隔分钟列表
      testData: [],
      messageContentVisible: false, // 消息ID输入框下显示的消息标题和消息内容
      messageVisible: false, // 选择消息弹窗是否显示
      paginationVisible: false, // 选择消息弹窗分页是否显示
      testmodel: '',
      remindTimeEdit: false,
      value3: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
      messageForm: { // 消息弹窗Form
        pageNum: 1,
        tabelData: [],
        messageId: '', // 消息编号
        messageIdQuery: '', // 弹窗中搜索消息编号
        messageTitle: '', // 消息标题
        content: '', // 消息内容
        customType: '', // 用户类型
        remindWay: [], // 提醒方式（推送，短信）
        isQidong: true, // 是否启动App进入首页
        tuisong: true, // 推送
        text: true, // 短信
        isPriority: false, // 是否优先
        jiangeTime: [], // pushMode为1时的间隔时间
        hours: 0, // 间隔小时
        mins: 0, // 间隔分钟
        isAndroid: true, // android是否发送
        isIOS: true, // IOS是否发送
        startTimes: [], // pushMoe为2时的间隔时间
        pushMode: '1', // 提醒方式（1自定义，2循环）
        datePicker1: '', // 自定义提醒时间1
        datePickerForm: [] // 自定义提醒时间1-4
      },
      customTypeList: ['全部', '活跃用户', '流失用户'],
      filterFormFro: {
        tableData: [],
        allPages: 0
      },
      mesageList: [], // 消息查询表
      filterForm: {
        category: ''
      },
      noteVisible: false,
      formLabelWidth: '30%',
      addForm: {
        messageId: '',
        messageTitle: '',
        content: ''
      },
      addVisable: false,
      tableData: [],
      editVisable: false,
      pickerOptions0: {
        disabledDate (time) {
          return time.getTime() < Date.now() - 8.64e7
        }
      },
      messageFormRules: {
        messageId: [
          { required: true, message: '请填写提醒内容', trigger: 'change' },
          { validator: checkHotlineNum, trigger: 'blur' }
        ],
        isSend: [
          { validator: checkSend, trigger: 'blur' }
        ],
        isRemind: [
          { validator: checkRemind, trigger: 'blur' }
        ],
        tuisong: [
          { required: true, message: '请选择', trigger: 'change' }
        ],
        jiangeTime: [
          { validator: checkJianGe, trigger: 'blur' }
        ],
        customType: [
          { required: true, message: '请选择发送对象', trigger: 'change' }
        ],
        hoursMins: [
          { validator: checkHoursMins, trigger: 'blur' }
        ],
        roundNum: [
          { validator: checkRoundNum, trigger: 'blur' }
        ],
        remindTime: [
          { validator: checkRemindTime, trigger: 'blur' }
        ],
        dataPickerTime: [
          { validator: checkDataPicker, trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    // 获得循环次数
    setRoundNum () {
      let timeTotal = ''
      let timeJiange = ''
      let timeNum = 0
      if (this.messageForm.jiangeTime) {
        timeTotal = new Date(this.messageForm.jiangeTime[1]).getTime() - new Date(this.messageForm.jiangeTime[0]).getTime()
        timeJiange = this.messageForm.hours * 3600 * 1000 + this.messageForm.mins * 60 * 1000
        timeNum = 0
      }
      if (timeJiange !== 0 && timeTotal) {
        timeNum = timeTotal / timeJiange
      } else {
        timeNum = 0
      }
      return timeNum
    }
  },
  methods: {
    // 编号输入框将小写字母转为大写，过滤特殊符号
    enterEvent (ev, form, value) {
      this[form][value] = this[form][value].replace(/[^\w]/g, '')
      this[form][value] = this[form][value].toUpperCase()
    },
    // 更换提醒时间类型时设置各种输入框是否可用
    changeRemindTime () {
      if (this.messageForm.pushMode === '1') {
        this.remindTimeEdit = false
      } else {
        this.remindTimeEdit = true
      }
    },
    // 将时间从时间戳转化为字符串显示
    formatDateFro (now) {
      var year = now.getFullYear()
      var month = now.getMonth() + 1
      month = month < 10 ? '0' + month : month
      var date = now.getDate()
      date = date < 10 ? ('0' + date) : date
      var hour = now.getHours()
      hour = hour < 10 ? ('0' + hour) : hour
      var minute = now.getMinutes()
      minute = minute < 10 ? ('0' + minute) : minute
      var second = now.getSeconds()
      second = second < 10 ? ('0' + second) : second
      return year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second
    },
    // 提醒方式选择
    setRemindWay () {
      this.messageForm.remindWay = []
      if (this.messageForm.tuisong) {
        this.messageForm.remindWay.push(this.messageForm.tuisong)
      }
      if (this.messageForm.text) {
        this.messageForm.remindWay.push(this.messageForm.text)
      }
    },
    // 选择消息弹窗双击事件
    doubleClick (row, event) {
      this.messageForm.messageTitle = row.messageTitle
      this.messageForm.content = row.content
      this.messageForm.messageId = row.messageId
      this.messageContentVisible = true
      this.messageVisible = false
    },
    // 分页页面跳转时
    handleCurrentChange (val) {
      this.messageForm.pageNum = val
      this.getMessageListFro()
    },
    // 提交自定义提醒策略前的验证
    submitAdd () {
      this.$refs['messageForm'].validate((valid) => {
        if (valid) {
          let para = {
            header: JSON.stringify({
              token: sessionStorage.getItem('token'),
              beanId: 'messageService_v1'
            }),
            body: JSON.stringify({
              messageId: this.messageForm.messageId
            })
          }
          apiBus.getMessageById(para).then(res => {
            this.messageContentVisible = false
            if (res.data.body.result === 1000) {
              let resData = res.data.body.content
              if (resData) {
                this.messageContentVisible = true
                this.messageForm.messageTitle = resData.messageTitle
                this.messageForm.content = resData.content
                this.$confirm('确定提交自定义提醒策略吗?', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  this.setStrateFro()
                })
              } else {
                this.$message.warning('没有对应自定义提醒内容，请重新选择编号！')
                return
              }
            } else {
              this.$message.error(res.data.body.resultDesp)
              return
            }
          }).catch(error => {
            this.$message.error(error)
            return
          })
        } else {
          return false
        }
      })
    },
    // 点击增加按钮，增加自定义选择时间
    addDatePicker () {
      if (this.messageForm.datePickerForm.length > 3) {
        this.$message.warning('时间区间最多只能选择5个！')
      } else {
        this.messageForm.datePickerForm.push({
          value: '',
          key: Date.now()
        })
      }
    },
    tableHeaderClassName ({row, column, rowIndex, columnIndex}) {
      if (rowIndex === 0) {
        return 'headerClass'
      }
    },
    tableRowClassName ({row, rowIndex}) {
      return ''
    },
    // 重置表单
    resetForm (formName) {
      this.$nextTick(function () {
        this.$refs[formName].resetFields()
        this.messageForm.hours = 0
        this.messageForm.mins = 0
        this.messageContentVisible = false
        if (this.messageForm.pushMode === '2') {
          // this.messageForm.jiangeTime = []
          this.messageForm.datePicker1 = ''
          this.messageForm.datePickerForm = []
        }
      })
    },
    /** 向后台请求数据 */
    // 向后台请求弹窗消息内容
    getMessageListFro (type) {
      this.messageVisible = true
      this.loading = true
      let para = {
        header: JSON.stringify({
          token: sessionStorage.getItem('token'),
          beanId: 'messageService_v1'
        }),
        body: JSON.stringify({
          pageNum: parseInt(this.messageForm.pageNum)
        })
      }
      this.filterFormFro.tableData = this.testData
      apiBus.getMessageList(para).then(res => {
        this.loading = false
        if (res.data.body.result === 1000) {
          let resData = res.data.body.content
          this.filterFormFro.tableData = resData.messages
          for (let i = 0; i < this.filterFormFro.tableData.length; i++) {
            this.filterFormFro.tableData[i].index = (this.messageForm.pageNum - 1) * 15 + i + 1
          }
          this.filterFormFro.allPages = resData.allPages
          this.filterFormFro.allPages > 1 ? this.paginationVisible = true : this.paginationVisible = false
        } else {
          this.$message.error(res.data.body.resultDesp)
        }
      })
      .catch(error => {
        this.loading = false
        this.$message.error(error)
      })
    },
    // 从存储到本地的message中查询输入编号是否存在
    isHaveMessage () {
      console.log('isHaveMessage')
      let para = {
        header: JSON.stringify({
          token: sessionStorage.getItem('token'),
          beanId: 'messageService_v1'
        }),
        body: JSON.stringify({
          messageId: this.messageForm.messageId
        })
      }
      apiBus.getMessageById(para).then(res => {
        console.log('getMessageById回参')
        console.log(res)
        this.messageContentVisible = false
        if (res.data.body.result === 1000) {
          let resData = res.data.body.content
          if (resData) {
            this.messageContentVisible = true
            this.messageForm.messageTitle = resData.messageTitle
            this.messageForm.content = resData.content
            console.log('1')
            return true
          } else {
            this.$message.warning('没有对应自定义提醒内容，请重新选择编号！')
            console.log('2')
            return false
          }
        } else {
          this.$message.error(res.data.body.resultDesp)
          console.log('3')
          return false
        }
      }).catch(error => {
        console.log('4')
        this.$message.error(error)
        return false
      })
    },
    // 向后台请求弹窗消息内容
    getMessageByIdFro (type) {
      let messageId = ''
      type === 1 ? messageId = this.messageForm.messageId : messageId = this.messageForm.messageIdQuery
      let para = {
        header: JSON.stringify({
          token: sessionStorage.getItem('token'),
          beanId: 'messageService_v1'
        }),
        body: JSON.stringify({
          messageId: messageId
        })
      }
      this.messageForm.tableData = this.testData
      apiBus.getMessageById(para).then(res => {
        if (res.data.body.result === 1000) {
          let resData = res.data.body.content
          if (resData) {
            if (type === 1) { // 直接点击“选择”
              this.messageContentVisible = true
              this.messageForm.messageTitle = resData.messageTitle
              this.messageForm.content = resData.content
            } else { // 在挑选弹窗的输入框中进行查询ID
              this.filterFormFro.tableData = []
              this.filterFormFro.tableData.push({
                'messageId': resData.messageId,
                'content': resData.content,
                'messageTitle': resData.messageTitle,
                'index': 1
              })
              this.filterFormFro.allPages = 1
              this.paginationVisible = false
            }
          } else {
            this.$message.warning('没有相关消息内容！')
            if (type === 1) {
              this.messageContentVisible = false
            }
          }
        } else {
          this.$message.error(res.data.body.resultDesp)
        }
      })
      .catch(error => {
        this.$message.error(error)
      })
    },
    // 向后台请求弹窗消息内容
    getMessageFro () {
      console.log('getMessageFro入参')
      let para = {
        header: JSON.stringify({
          token: sessionStorage.getItem('token'),
          beanId: 'messageService_v1'
        }),
        body: JSON.stringify({
          messageId: this.messageForm.messageId
        })
      }
      console.log(para)
      this.messageForm.tableData = []
      apiBus.getMessageById(para).then(res => {
        console.log('getMessageFro回参')
        if (res.data.body.result === 1000) {
          let resData = res.data.body.content
          if (resData) {
            this.messageForm.tableData = []
            this.messageForm.tableData.push({
              'messageId': resData.messageId,
              'content': resData.content,
              'messageTitle': resData.messageTitle,
              'index': 1
            })
          }
        } else {
          this.$message.error(res.data.body.resultDesp)
        }
      })
      .catch(error => {
        this.$message.error(error)
      })
    },
    // 向后台提交自定义提醒策略
    setStrateFro () {
      let startTimes = []
      let startTime = null
      let expireTime = null
      if (this.messageForm.jiangeTime && this.messageForm.jiangeTime.length > 0) {
        startTime = this.formatDateFro(this.messageForm.jiangeTime[0])
        expireTime = this.formatDateFro(this.messageForm.jiangeTime[1])
      }
      if (this.messageForm.datePicker1 && this.messageForm.datePicker1 !== '') {
        startTimes.push(this.formatDateFro(this.messageForm.datePicker1))
      }
      for (let i = 0; i < this.messageForm.datePickerForm.length; i++) {
        if (this.messageForm.datePickerForm[i].value && this.messageForm.datePickerForm[i].value !== '') {
          startTimes.push(this.formatDateFro(this.messageForm.datePickerForm[i].value))
        }
      }
      let para = {
        header: JSON.stringify({
          token: sessionStorage.getItem('token')
        }),
        body: JSON.stringify({
          messageId: this.messageForm.messageId,
          customType: this.messageForm.customType, // 发送对象
          isPush: this.messageForm.tuisong, // 是否推送
          pushMode: parseInt(this.messageForm.pushMode), // 推送方式（1是循环；2是自定义）
          startTime: startTime,
          expireTime: expireTime,
          hours: this.messageForm.hours,
          mins: this.messageForm.mins,
          startTimes: startTimes,
          isAndroid: this.messageForm.isAndroid,
          isIOS: this.messageForm.isIOS,
          isSMS: this.messageForm.text
        })
      }
      apiBus.setStrate(para).then(res => {
        if (res.data.body.result === 1000) {
          if (res.data.body.content.success === res.data.body.content.num) {
            this.$message.success('成功设置自定义提醒策略')
            this.resetForm('messageForm')
          } else {
            this.$message.error('推送失败')
          }
        } else {
          this.$message.error(res.data.body.resultDesp)
        }
      })
      .catch(error => {
        this.$message.error(error)
      })
    }
  },
  mounted () {
    this.marginWidth = (document.body.scrollWidth - 219) / 2 - (640 / 2) - 20 - 60
  }
}
</script>